home *** CD-ROM | disk | FTP | other *** search
/ Complete Internet Archive / Complete Internet Archive.iso / Web Boards / WebForum_tar(2).Z / WebForum_tar(2) / WebForum / src / wfcommand.pl < prev   
Encoding:
Text File  |  1995-01-23  |  5.2 KB  |  172 lines

  1. #
  2. # wfcommand: generic page loader
  3. #
  4. # Copyright (C) 1994 Afzal Ballim
  5.  
  6. require "ABSWFBIN/LIBWEBFORUM.PL";
  7.  
  8. # read the input from the form.
  9. %in=&WFReadParse;
  10.  
  11. # subject has to have / protected and ^ 
  12. #if ($in{"subject"} ne "") {
  13. #    $in{"subject"} =~ s#([^\\])/#$1\ª#g;
  14. #    $in{"subject"} =~ s#\^#\╖#g;
  15. #}
  16.  
  17. # The command is given via PATH_INFO or form variables.
  18. # The PATH_INFO version takes precedence.
  19.  
  20. %pi=&WFDecodePathInfo;
  21.  
  22. if ($pi{"command"}) {
  23.  $in{"command"}=$pi{"command"};
  24. }
  25.  
  26. #let's get the easy bit out of the way: a header
  27. &WFHtmlHeader;
  28.  
  29. # Now, let's process that command.
  30. if (!$in{"command"}) {
  31.     &WFError(
  32. "<p>Something weird has happened and I can't find what
  33. command you gave me. Try contacting CREATOR.
  34. Useful information to include with your error message
  35. would be the command you <i>thought</i> you were
  36. calling.</p>
  37. <p><i>Note:</i> This may have been caused because you tried
  38. to reload the page. Unfortunately, these pages are not (currently)
  39. reload-able with the reader's reload function. You must instead
  40. click on the 'Rescan' button supplied with the pages.</p>
  41.  
  42. <p>Please note, that due to the complexity of this system,
  43. not all client programs will function with it. Lynx 2.3
  44. does not work, and I do not know of any line-based client
  45. that does. NCSA Mosaic 2.4 works, as does Netscape 0.9.");
  46.  
  47.     exit;
  48. }
  49.                 
  50. # The set of supported commands.
  51. # Commands return a null string if they succeed, or an
  52. # error message if they don't.
  53. # When a command fails, we try another command if we can
  54. # The onfail list is just a convenient table of command
  55. # failure changes.
  56. %onfail= ("top","",
  57.       "forum","top",
  58.       "subject","forum",
  59.       "message","subject",
  60.       "nextmessage","subject",
  61.       "prevmessage","subject",
  62.       "reply","message",
  63.       "followup","subject",
  64.       "post","forum",
  65.       "cancel","message",
  66.       "mkmsg","subject");
  67.       
  68. $CommandToDo=$in{"command"};
  69.  
  70. # Logging
  71. if (LOGLEVEL != 0) {
  72.  if ((LOGLEVEL == 1) && $in{"command"} eq "top") {
  73.     system("echo `/bin/date` $ENV{REMOTE_USER} >> LOGFILE");
  74.  }
  75.  else {
  76.     $lstring="$ENV{REMOTE_USER}:" . 
  77.              $in{"command"} . "/" .
  78.              &WFDecodeDatum($in{"forum"}) . "/" .
  79.              &WFDecodeDatum($in{"subject"}) . "/" .
  80.              &WFDecodeDatum($in{"message"});
  81.     system("echo `/bin/date` '$lstring' >>LOGFILE");
  82.  } 
  83. }
  84.  
  85. while ($CommandToDo ne "exit") {
  86.  The_Commands: {
  87.   $CommandToDo eq "" && &WFError("No Command!") && exit(1);
  88.  
  89.   $CommandToDo eq "top" && do {
  90.     require "ABSWFCTRLBIN/STD_TOP.PL";
  91.     if (($WFCR=&WFCommandTop(%in)) ne ""){
  92.         &WFError($WFCR);
  93.     $CommandToDo=$onfail{"top"};last The_Commands;};
  94.     $CommandToDo="exit";last The_Commands;};
  95.  
  96.   $CommandToDo eq "forum" && do {
  97.     require "ABSWFCTRLBIN/STD_FORUM.PL";
  98.     if (($WFCR=&WFCommandForum(%in)) ne ""){
  99.         &WFError($WFCR);
  100.     $CommandToDo=$onfail{"forum"};last The_Commands;}
  101.     $CommandToDo="exit";last The_Commands;};
  102.  
  103.   $CommandToDo eq "subject" && do {
  104.     require "ABSWFCTRLBIN/STD_SUBJECT.PL";
  105.     if (($WFCR=&WFCommandSubject("first",%in)) ne ""){
  106.         &WFError($WFCR);
  107.     $CommandToDo=$onfail{"subject"};last The_Commands;};
  108.     $CommandToDo="exit";last The_Commands;};
  109.  
  110.   $CommandToDo eq "message" && do {
  111.     require "ABSWFCTRLBIN/STD_SUBJECT.PL";
  112.     if (($WFCR=&WFCommandSubject("this",%in)) ne ""){
  113.         &WFError($WFCR);
  114.     $CommandToDo=$onfail{"message"};last The_Commands;};
  115.     $CommandToDo="exit";last The_Commands;};
  116.  
  117.   $CommandToDo eq "nextmessage" && do {
  118.     require "ABSWFCTRLBIN/STD_SUBJECT.PL";
  119.     if (($WFCR=&WFCommandSubject("next",%in)) ne ""){
  120.         &WFError($WFCR);
  121.     $CommandToDo=$onfail{"nextmessage"};last The_Commands;};
  122.     $CommandToDo="exit";last The_Commands;};
  123.  
  124.   $CommandToDo eq "prevmessage" && do {
  125.     require "ABSWFCTRLBIN/STD_SUBJECT.PL";
  126.     if (($WFCR=&WFCommandSubject("prev",%in)) ne ""){
  127.         &WFError($WFCR);
  128.     $CommandToDo=$onfail{"prevmessage"};last The_Commands;};
  129.     $CommandToDo="exit";last The_Commands;};
  130.  
  131.   $CommandToDo eq "post" && do {
  132.     require "ABSWFCTRLBIN/STD_POST.PL";
  133.     if (($WFCR=&WFCommandPost("post",%in)) ne ""){
  134.         &WFError($WFCR);
  135.     $CommandToDo=$onfail{"post"};last The_Commands;};
  136.     $CommandToDo="exit";last The_Commands;};
  137.  
  138.   $CommandToDo eq "followup" && do {
  139.     require "ABSWFCTRLBIN/STD_POST.PL";
  140.     if (($WFCR=&WFCommandPost("followup",%in)) ne ""){
  141.         &WFError($WFCR);
  142.     $CommandToDo=$onfail{"followup"};last The_Commands;};
  143.     $CommandToDo="exit";last The_Commands;};
  144.  
  145.   $CommandToDo eq "reply" && do {
  146.     require "ABSWFCTRLBIN/STD_POST.PL";
  147.     if (($WFCR=&WFCommandPost("reply",%in)) ne ""){
  148.         &WFError($WFCR);
  149.     $CommandToDo=$onfail{"reply"};last The_Commands;};
  150.     $CommandToDo="exit";last The_Commands;};
  151.  
  152.   $CommandToDo eq "mkmsg" && do {
  153.     require "ABSWFCTRLBIN/STD_MKMSG.PL";
  154.     if (($WFCR=&WFCommandMkmsg(%in)) ne ""){
  155.         &WFError($WFCR);
  156.     $CommandToDo=$onfail{"mkmsg"};last The_Commands;};
  157.     $CommandToDo="subject";last The_Commands;};
  158.  
  159.   $CommandToDo eq "cancel" && do {
  160.     require "ABSWFCTRLBIN/STD_CANCEL.PL";
  161.     if (($WFCR=&WFCommandCancel(%in)) ne ""){
  162.         &WFError($WFCR);
  163.     $CommandToDo=$onfail{"cancel"};last The_Commands;};
  164.     $CommandToDo="subject";last The_Commands;};
  165.  
  166.   do {
  167.     &WFError("Unknown or unimplemented command: $CommandToDo\n");
  168.     $CommandToDo="top";
  169.   }
  170.  }
  171. }
  172.